<template>
<div class="quo-simple-lists">
  <div class="quo-simple-list"  v-for="quo in quotions">
    <div class="simple-list-up">
      <div class="list-up-left">{{quo.tid}}</div>
      <div class="list-up-mid">订单日期</div>
      <div class="list-up-right" :class="getState(quo.state).color">{{quo.state}}</div>
    </div>
    <div class="simple-list-mid" @click="toQuoInf(quo,getPoster(quo.pid3),getSender(quo.pid1),person)">
      <div class="list-mid-up">
        <div class="mid-up-left" v-html="'报单员：'+getPoster(quo.pid3)"></div>
        <div class="mid-up-mid" v-html="'派单员：'+getSender(quo.pid1)"></div>
        <div class="mid-up-right">接单员</div>
      </div>
      <div class="list-mid-down">
        <span>{{quo.activityTheme}}</span>
      </div>
    </div>
    <div class="simple-list-down">
      <div class="list-down-left">
        <span class="list-down-span"></span>
        <span>活动报价</span>
      </div>
      <div class="list-down-mid">
        <span class="list-down-span"></span>
        <span>产品报价</span>
      </div>
      <div class="list-down-right">
        <span class="list-down-span"></span>
        <span>合同</span>
      </div>
    </div>
  </div>
</div>
</template>

<script>
import {request} from "../network/request";

export default {
  name: "quoList",
  props:{
    quotions:[],
    person:{}
  },
  data(){
    return{
      color:'',
      poster:'',
      sender:''
    }
  },
  methods:{
    getState:function (states){
      let color = '';
      switch (states){
        case "草稿":
          color = "green"
          break
        case "待派单":
          color = "green"
          break
        case "待接单":
          color = "black"
           break
        case "进行中":
          color = "black"
           break
        case "已暂停":
          color = "grey"
           break
        case "待评价":
          color = "red"
          break
        case "已完成":
          color = "red"
              break
      }
      return {
        color
      }
    },
    getPoster:function (pid3){
      let perName = ''
      request({
        url:'/findPerson',
        params:{
          pid:pid3
        }
      }).then(res =>{
        perName = res.data.personName
        this.poster = perName
      }).catch(err =>{})
      return this.poster
    },
    getSender:function (pid1){
      let perName = ''
      request({
        url:'/findPerson',
        params:{
          pid:pid1
        }
      }).then(res =>{
        perName = res.data.personName
        this.sender = perName
        console.log(perName);
      }).catch(err =>{})
      return this.sender
    },
    toQuoInf:function (quo,posname,senname,person){
      let metplaces = []
      request({
        url:'/listTaskFormByTid',
        params:{
          tid:quo.tid
        }
      }).then(res =>{
        metplaces = res.data
        console.log(metplaces)
        this.$router.push({
          path:'/postquoinf',
          query:{
            quo:quo,
            posname:posname,
            senname:senname,
            person:person,
            metplaces:metplaces
          }
        })
      }).catch(err =>{})
    }
  }
}
</script>

<style scoped>

</style>
